#include <bits/stdc++.h>
using namespace std;

struct node {
    int l, r, flag, ans;
    node(int l1, int r1, int flag1, int ans1)
    {
        l = l1, r = r1, flag = flag1, ans = ans1;
    }
    bool operator<(const node& a) const
    {
        return l < a.l;
    }
    bool operator>(const node& a) const
    {
        return l > a.l;
    }
};

int n, p[200005];
set<node> s;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> p[i];
    s.insert(node(0, n + 1, 0, 0));
    for (int i = 1; i <= n; i++) {
        auto x = s.upper_bound(node(p[i], p[i], 0, 0));
        x--;
        node q = *x;
        s.erase(x);
        if (q.flag == 1)
            s.insert(node(p[i], q.r, 0, q.ans + 1));
        else
            s.insert(node(p[i], q.r, 0, q.ans));
        s.insert(node(q.l, p[i], 1, q.ans));
    }
    for (auto x : s)
        cout << x.ans << endl;
    return 0;
}